﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HU8.Helpers.Base
{
    /// <summary>
    /// 表示带有成功失败信息的JSON返回对象
    /// </summary>
    public class JsonResponse
    {
        public bool success { get; set; }
        public string message { get; set; }
        public object data { get; set; } //顺带的Json Data

        public JsonResponse()
        {
            success = false;
            message = string.Empty;
        }

        #region AppendMessage       Chiron
        /// <summary>
        /// 追加信息
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="se"></param>
        public void AppendMessage(string msg, string se = "<br/>")
        {
            if (!string.IsNullOrEmpty(msg))
            {
                if (message == null) message = string.Empty;
                message += msg + (se ?? string.Empty);
            }
        }

        /// <summary>
        /// 追加信息
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="se"></param>
        public void AppendMessage(Exception ex, string se = "<br/>")
        {
            if (ex != null) AppendMessage(ex.Message, se);
        }
        #endregion AppendMessage
    }

    public class JsonImageResponse : JsonResponse
    {
        public JsonSize size { get; set; }
        public JsonImageResponse()
        {
            size = new JsonSize();
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class JsonSize
    {
        public int width { get; set; }
        public int height { get; set; }
    }
}